﻿using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTTypeDeclDelegate : ASTNamespaceTypeDecl
    {
        public          ASTType                 returnType      { get; set; }
        public readonly ASTTypeParamList        typeParamList   = new ASTTypeParamList      ();
        public readonly ASTFormalParamList      formalParamList = new ASTFormalParamList    ();
        public readonly ASTTypeConstraintList   constraints     = new ASTTypeConstraintList ();

        public override string ToString ()
        {
            depth ++;

            string mods = "";

            if (Mods.has(modifiers, Mods.unsafeMod)) mods += "unsafe ";
            if (Mods.has(modifiers, Mods.publicMod)) mods += "public ";
            if (Mods.has(modifiers, Mods.privateMod)) mods += "private ";
            if (Mods.has(modifiers, Mods.internalMod)) mods += "internal ";
            if (Mods.has(modifiers, Mods.protectedMod)) mods += "protected ";

            string sss = Strings.tab(depth) + mods + string.Format (
                "delegate {0} {1}{2} ({3}) {4};",
                returnType,
                name,
                typeParamList,
                formalParamList,
                constraints
            );

            depth --;

            return sss;
        }
    }
}
